<!DOCTYPE html>
<html>
<head>
	<meta charset="ISO-8859-1">
	<title>Insert title here</title>

 	<script type='text/javascript' src="js/jquery/jquery-1.10.2.min.js"></script>
	<script type='text/javascript' src="js/jquery/jquery-ui-1.10.3.custom.min.js"/></script>
	<link rel="stylesheet" href="css/bootstrap.flatly.min.css" type="text/css" />	
	<link rel="stylesheet" href="css/stickyFooter.css" type="text/css" />
	<script type="text/javascript" src="js/bootstrap.min.js"></script>	
</head>
<body>
	<h1 id="onlyHeader">ARG</h1>
	
	<div>
		<p id="result"></p>
	</div>
	
	<div id="smatthaiTbl">
	</div>
	
	
    <script type="text/javascript">
    	if (!isAsync) {
    		syncCall();
    	}
    </script>
    	<script type="text/javascript">
		//$ refers to most recent jquery
		var emp = emp || {};		

		var smatthai = smatthai || {};
		
	</script>	
    <script src="js/manager.debug.js" type="text/javascript"></script>
    <script src="js/smatthai.formbuilder.js" type="text/javascript"></script>
    <script type="text/javascript">		
    	var isAsync = true;
	     //TODO: Load from config file	     
	    var path = "http://localhost:8080/emp-config/admin/mapengine/config/getMapConfiguration";
	    var args = { path: path, isAsync: isAsync, callback: function() { asyncCall(); } };
        emp.configManager.load(args);        
		
		function asyncCall() {
			console.log("async call");
			updatePage(0);
        };
        
        function syncCall() {
			console.log("sync call");
			updatePage(1);
        };
        
        function updatePage(idx) {
        	var res = configManager.config.mapEngines[idx].name;
    		$("#result").html(res);
    		$('#onlyHeader').html(res);
        }
        
        var tbl_model = {"divId":"smatthaiTbl", headers: [ {"name":"id","hidden":false}, {"name":"Value"}, {"name":"URL"} ], data: [{"id":5, "value":"forty", "url":"http://localhost.com"},{"id":52, "value":"fortyTwo", "url":"http://localhost2.com"},{"id":53, "value":"fortyfive", "url":"http://localhost3.com"}] };
        
        
        smatthai.formbuilder.build(tbl_model);
    </script>
</body>
</html>